package com.healthy.education.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.healthy.common.log.annotation.Log;
import com.healthy.common.log.enums.BusinessType;
import com.healthy.common.security.annotation.RequiresPermissions;
import com.healthy.education.domain.OnlineLiveEvents;
import com.healthy.education.service.IOnlineLiveEventsService;
import com.healthy.common.core.web.controller.BaseController;
import com.healthy.common.core.web.domain.AjaxResult;
import com.healthy.common.core.utils.poi.ExcelUtil;
import com.healthy.common.core.web.page.TableDataInfo;

/**
 * 直播活动Controller
 * 
 * @author 束伟
 * @date 2024-03-29
 */
@RestController
@RequestMapping("/OnlineLiveEvents")
public class OnlineLiveEventsController extends BaseController
{
    @Autowired
    private IOnlineLiveEventsService onlineLiveEventsService;

    /**
     * 查询直播活动列表
     */
    @RequiresPermissions("education:OnlineLiveEvents:list")
    @GetMapping("/list")
    public TableDataInfo list(OnlineLiveEvents onlineLiveEvents)
    {
        startPage();
        List<OnlineLiveEvents> list = onlineLiveEventsService.selectOnlineLiveEventsList(onlineLiveEvents);
        return getDataTable(list);
    }

    /**
     * 导出直播活动列表
     */
    @RequiresPermissions("education:OnlineLiveEvents:export")
    @Log(title = "直播活动", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OnlineLiveEvents onlineLiveEvents)
    {
        List<OnlineLiveEvents> list = onlineLiveEventsService.selectOnlineLiveEventsList(onlineLiveEvents);
        ExcelUtil<OnlineLiveEvents> util = new ExcelUtil<OnlineLiveEvents>(OnlineLiveEvents.class);
        util.exportExcel(response, list, "直播活动数据");
    }

    /**
     * 获取直播活动详细信息
     */
    @RequiresPermissions("education:OnlineLiveEvents:query")
    @GetMapping(value = "/{liveEventId}")
    public AjaxResult getInfo(@PathVariable("liveEventId") Long liveEventId)
    {
        return success(onlineLiveEventsService.selectOnlineLiveEventsByLiveEventId(liveEventId));
    }

    /**
     * 新增直播活动
     */
    @RequiresPermissions("education:OnlineLiveEvents:add")
    @Log(title = "直播活动", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OnlineLiveEvents onlineLiveEvents)
    {
        return toAjax(onlineLiveEventsService.insertOnlineLiveEvents(onlineLiveEvents));
    }

    /**
     * 修改直播活动
     */
    @RequiresPermissions("education:OnlineLiveEvents:edit")
    @Log(title = "直播活动", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OnlineLiveEvents onlineLiveEvents)
    {
        return toAjax(onlineLiveEventsService.updateOnlineLiveEvents(onlineLiveEvents));
    }

    /**
     * 删除直播活动
     */
    @RequiresPermissions("education:OnlineLiveEvents:remove")
    @Log(title = "直播活动", businessType = BusinessType.DELETE)
	@DeleteMapping("/{liveEventIds}")
    public AjaxResult remove(@PathVariable Long[] liveEventIds)
    {
        return toAjax(onlineLiveEventsService.deleteOnlineLiveEventsByLiveEventIds(liveEventIds));
    }
}
